home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 5 / Amiga Tools 5.iso / tools / developer-tools / c-tools / c_examples / appmenu / appmenu.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-14  |  1.5 KB  |  62 lines

  1. //////////////////////////////////////////////////////////////////////////////
  2. // AppMenu.cpp
  3. //
  4. // Deryk Robosson
  5. // May 9, 1996
  6. //////////////////////////////////////////////////////////////////////////////
  7.  
  8. //////////////////////////////////////////////////////////////////////////////
  9. // INCLUDES
  10. #include "aframe:include/AppMenu.hpp"
  11.  
  12. //////////////////////////////////////////////////////////////////////////////
  13. //
  14.  
  15. AFAppMenu::AFAppMenu()
  16.     :WorkbenchBase(NULL),
  17.     IconBase(NULL)
  18. {
  19.     if(!WorkbenchBase) {
  20.         if(!(WorkbenchBase=(struct WorkbenchBase*)OpenLibrary((UBYTE*)"workbench.library",(ULONG)36)))
  21.             printf("failed to open workbench.library\n");
  22.     }
  23.  
  24.     if(!IconBase) {
  25.         if(!(IconBase=(struct IconBase*)OpenLibrary((UBYTE*)"icon.library",(ULONG)36)))
  26.             printf("failed to open icon.library\n");
  27.     }
  28. }
  29.  
  30. AFAppMenu::~AFAppMenu()
  31. {
  32.     if(am) {
  33.         RemoveAppMenuItem(am);
  34.         am=NULL;
  35.     }
  36.     if(WorkbenchBase) {
  37.         CloseLibrary((struct Library*)WorkbenchBase);
  38.         WorkbenchBase=NULL;
  39.     }
  40.     if(IconBase) {
  41.         CloseLibrary((struct Library*)IconBase);
  42.         IconBase=NULL;
  43.     }
  44. }
  45.  
  46. BOOL AFAppMenu::AddItem(AFWindow *window, UBYTE* name, ULONG menuid, LPMsgPort appmsgport)
  47. {
  48.     m_menuid=menuid;
  49.     m_itemname=name;
  50.     m_pwindow=window;
  51.  
  52.     if(am = (struct AppMenuItem*)AddAppMenuItem(m_menuid, (ULONG)0, m_itemname, appmsgport, NULL))
  53.         return TRUE;
  54.     else return FALSE;
  55. }
  56.  
  57. void AFAppMenu::RemoveItem()
  58. {
  59.     RemoveAppMenuItem(am);
  60.     am=NULL;
  61. }
  62.